/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import DAO.Iter.LevelDao;
import TableModel.Level;
import java.io.Serializable;
import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

/**
 *
 * @author vt
 */
public class LevelDaoImpl extends HibernateDaoSupport implements LevelDao{

    @Override
    public List<TableModel.Level> getAllLevel() {
       return this.getHibernateTemplate().find("from Level level order by level.maLevel");
    }
    @Override
    public TableModel.Level getLevel(String id) {
        List<Level> list = this.getHibernateTemplate().find("from Level level where level.maLevel =?",id);
        if(!list.isEmpty()){
            return (Level)list.get(0);
        }
        return null;
    }

    @Override
    public void add(TableModel.Level a) {
       this.getHibernateTemplate().save(a);
    }

    @Override
    public void update(TableModel.Level a) {
       this.getHibernateTemplate().update(a);
    }
    @Override
    public void delete(TableModel.Level a) {
       this.delete(a);
    }

    
}
